package com.ruoyi.common.sql;

import com.ruoyi.common.enums.BaseString;
import com.ruoyi.common.exception.ServiceException;
import lombok.Getter;

import java.util.Arrays;
@Getter
public enum JoinTypeEnum implements BaseString {
    INNER("INNER","INNER"),
    LEFT("LEFT","LEFT"),
    RIGHT("RIGHT","RIGHT");
    private final String code;
    private final String desc;
    JoinTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 可选：每个枚举类可以定义自己的fromCode方法
    public static JoinTypeEnum fromCode(String code) {
        return BaseString.fromCode(JoinTypeEnum.class, code);
    }


    @Override
    public JoinTypeEnum valOf(String code) {
        return Arrays.stream(JoinTypeEnum.values()).filter(item -> item.code.equals(code)).findFirst().orElseThrow(() -> new ServiceException("枚举转换异常"));
    }
}
